package com.shadow.common.exception;

import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 系统全局异常处理.
 * */
@RestControllerAdvice
public class SysExceptionHandler {

    /**
     * 全局异常处理
     *
     */
    @ExceptionHandler(RuntimeException.class)
    public String exception(Exception e){
        e.printStackTrace();
        return "error";
    }

    /**
     * 未授权异常==>统一跳转东到未授权页面
     *
     */
    @ExceptionHandler(AuthorizationException.class)
    public String authorizationExceptionHandle(Exception e) {
        e.printStackTrace();
        return "unauthorized";
    }
}
